package bancosys.tec.persist.persister.listener;

import bancosys.tec.persist.authorization.Authorizable;
import bancosys.tec.persist.persister.PersistenceAction;

/**
 * Adapter para ver um {@link PersisterListener} como um {@link AuthorizablePersisterListener}
 * 
 * @author takeshi
 * @param <T> o tipo do {@link Authorizable}
 */
public final class AuthorizablePersisterListenerAdapter<T extends Authorizable> implements AuthorizablePersisterListener<T> {

    private final PersisterListener<T> delegate;

    /**
     * C'tor
     * 
     * @param delegate o delegate para onde encaminhar os metodos
     */
    public AuthorizablePersisterListenerAdapter(PersisterListener<T> delegate) {
        super();
        this.delegate = delegate;
    }

    /**
     * {@inheritDoc}
     * 
     * @see bancosys.tec.persist.persister.listener.PersisterListener#afterInsert(bancosys.tec.persist.Persistable)
     */
    public void afterInsert(T bean, Object action) {
        this.delegate.afterInsert(bean, action);
    }

    /**
     * {@inheritDoc}
     * 
     * @see bancosys.tec.persist.persister.listener.PersisterListener#afterRemove(bancosys.tec.persist.Persistable)
     */
    public void afterRemove(T bean) {
        this.delegate.afterRemove(bean);
    }

    /**
     * {@inheritDoc}
     * 
     * @see bancosys.tec.persist.persister.listener.PersisterListener#afterUpdate(bancosys.tec.persist.Persistable)
     */
    public void afterUpdate(T bean, Object action) {
        this.delegate.afterUpdate(bean, action);
    }

    /**
     * {@inheritDoc}
     * 
     * @see bancosys.tec.persist.persister.listener.PersisterListener#beforeInsert(bancosys.tec.persist.Persistable)
     */
    public void beforeInsert(T bean, Object action) {
        this.delegate.beforeInsert(bean, action);
    }

    /**
     * {@inheritDoc}
     * 
     * @see bancosys.tec.persist.persister.listener.PersisterListener#beforeRemove(bancosys.tec.persist.Persistable)
     */
    public void beforeRemove(T bean) {
        this.delegate.beforeRemove(bean);
    }

    /**
     * {@inheritDoc}
     * 
     * @see bancosys.tec.persist.persister.listener.PersisterListener#beforeUpdate(bancosys.tec.persist.Persistable)
     */
    public void beforeUpdate(T bean, Object action) {
        this.delegate.beforeUpdate(bean, action);
    }

    /**
     * {@inheritDoc}
     * 
     * @see bancosys.tec.persist.persister.listener.PersisterListener#doRemoveDependencies(bancosys.tec.persist.Persistable)
     */
    public void doRemoveDependencies(T bean) {
        this.delegate.doRemoveDependencies(bean);
    }

    /**
     * {@inheritDoc}
     * 
     * @see bancosys.tec.persist.persister.listener.PersisterListener#getTargetClass()
     */
    public Class<? extends T> getTargetClass() {
        return this.delegate.getTargetClass();
    }

    /**
     * {@inheritDoc}
     */
    public void beforeAuthorization(PersistenceAction action, T target) {
    }

    /**
     * {@inheritDoc}
     * 
     * @see bancosys.tec.persist.persister.listener.AuthorizablePersisterListener#afterInsertIntoColdPartition(bancosys.tec.persist.persister.PersistenceAction,
     * bancosys.tec.persist.authorization.Authorizable)
     */
    public void afterInsertIntoColdPartition(PersistenceAction action, T coldInstance) {
    }

    /**
     * {@inheritDoc}
     * 
     * @see bancosys.tec.persist.persister.listener.AuthorizablePersisterListener#afterUpdateColdInstance(bancosys.tec.persist.authorization.Authorizable)
     */
    public void afterUpdateColdInstance(T target) {
    }

    /**
     * {@inheritDoc}
     * 
     * @see bancosys.tec.persist.persister.listener.AuthorizablePersisterListener#beforeRejection(bancosys.tec.persist.persister.PersistenceAction,
     * bancosys.tec.persist.authorization.Authorizable)
     */
    public void beforeRejection(PersistenceAction action, T target) {
    }
}
